// 引入路由
import { createRouter, createWebHashHistory } from "vue-router"
const routes = [
    {
        path: "/",
        component: () => import("@/views/homepage/index.vue"),
        redirect: '/home',
        children: [
            {
                path: 'home',
                component: () => import('@/views/home.vue'),
            },
            //产品中心
            {
                path: 'ProductCenter',
                component: () => import('@/views/ProductCenter/index.vue'),
            },
            {
                path: 'ProductCenterInfo',
                component: () => import('@/views/ProductCenter/productInfo.vue'),
            },
            //解决方案
            {
                path: 'solution',
                component: () => import('@/views/solution/solution.vue'),
            },
            {
                path: 'solutionDetailed',
                component: () => import('@/views/solution/solutionDetailed.vue'),
            },
            //云咨询
            {
                path: 'CloudConsulting',
                component: () => import('@/views/CloudConsulting/CloudConsulting.vue'),
            },
            {
                path: 'CloudConsultingDetails',
                component: () => import('@/views/CloudConsulting/CloudConsultingDetails.vue'),
            },
            // 应用案例
            {
                path: 'applicationCase',
                component: () => import('@/views/applicationCase/applicationCase.vue'),
            },
            {
                path: 'applicationCaseDetailed',
                component: () => import('@/views/applicationCase/applicationCaseDetailed.vue'),
            },
            // 服务支持
            {
                path: 'serviceSupport',
                component: () => import('@/views/serviceSupport/serviceSupport.vue'),
            },
            // 关于我们
            {
                path: 'AttractTalents',
                component: () => import('@/views/about/AttractTalents.vue'),
            },
            {
                path: 'CollaborationMessage',
                component: () => import('@/views/about/CollaborationMessage.vue'),
            },
            {
                path: 'CompanyProfile',
                component: () => import('@/views/about/CompanyProfile.vue'),
            },
            {
                path: 'ContactInformation',
                component: () => import('@/views/about/ContactInformation.vue'),
            },
            {
                path: 'details',
                component: () => import('@/views/about/details.vue'),
            },
            {
                path: 'news',
                component: () => import('@/views/about/news.vue'),
            },
            {
                path: 'SkillService',
                component: () => import('@/views/about/SkillService.vue'),
            },
            {
                path: 'search',
                component: () => import('@/views/search/index.vue'),
            },
        ]
    }
]

const router = createRouter({
    history: createWebHashHistory(),
    routes,
    scrollBehavior(to, from, savedPosition) {
        if (to.hash) {
            return { selector: to.hash }; // 确保返回正确的选择器对象以滚动到锚点位置
        } else if (savedPosition) {
            return savedPosition; // 如果保存了位置，就返回该位置（例如，前进/后退按钮）
        } else {
            return { x: 0, y: 0 }; // 或者回到页面顶部等逻辑
        }
    }
})
export default router